package ee.az.geometry;

/**
 * @author Artur Zinatullin (artur.zinatullin@gmail.com) 2010
 */
public class Angle {

	public static double normalize(double angle) {
		if (Math.abs(angle) > 2*Math.PI) {
			angle = angle - Math.signum(angle) * 2*Math.PI * (long)(angle / (2*Math.PI));
		}
		if (angle < 0) {
			angle = angle + 2*Math.PI;
		}
		return angle;
	}
	
	public static double getAngle(double x, double y, double originX, double originY) {
		return normalize(-Math.PI/2 - Math.atan2(originX-x, originY-y));
	}
	
	public static int toDegrees(double a) {
		return (int) Math.round(180 / Math.PI * a);
	}
}
